package com.patterns.builder;

import java.util.Date;
import java.util.Objects;

/**
 * @Author Tanyu
 * @Date 2020/6/2 10:35
 * @Description 深拷贝
 * @Version 1.0
 */
public class Sheep2 implements Cloneable {

  private String sname;
  private Date birthday;

  @Override
  protected Object clone() throws CloneNotSupportedException {
    Object obj = super.clone();//直接调用object对象的clone()方法！

    //添加如下代码实现深复制(deep Clone)
    Sheep2 s = (Sheep2) obj;
    s.birthday = (Date) this.birthday.clone();
    return obj;
  }

  public Sheep2() {
  }

  public Sheep2(String sname, Date birthday) {
    this.sname = sname;
    this.birthday = birthday;
  }

  public String getSname() {
    return sname;
  }

  public void setSname(String sname) {
    this.sname = sname;
  }

  public Date getBirthday() {
    return birthday;
  }

  public void setBirthday(Date birthday) {
    this.birthday = birthday;
  }
}
